//
//  ZYCDutyRecordCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/23.
//

#import "ZYCDutyRecordCell.h"
#import "ZYCDutyBulletionRecordModel.h"
@interface ZYCDutyRecordCell ()

@property (nonatomic, strong) UIView *bgWhiteView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UILabel *line;
//值班人员
@property (nonatomic, strong) UILabel *dutyNamesLabel;
@property (nonatomic, strong) UILabel *endModifyTimeLabel;


@end
@implementation ZYCDutyRecordCell
- (void)setModel:(ZYCDutyBulletionRecordModel *)model{
    _model = model;
    _titleLabel.text = model.title;
    _dutyNamesLabel.text = [NSString stringWithFormat:@"值班人员:%@",model.dutyPersonnel];
    _statusLabel.text = model.currentStatusStr;
    if ([model.currentStatus integerValue] == 0) {//正常
        _statusLabel.textColor = HEX_RGB(@"#999999");
    }else{//逾期
        _statusLabel.textColor = HEX_RGB(@"#E93C06");
    }
    _endModifyTimeLabel.text = [NSString stringWithFormat:@"最后修改时间:%@",model.lastUpdateTime];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.bgWhiteView];
        [self.bgWhiteView addSubview:self.titleLabel];
        [self.bgWhiteView addSubview:self.statusLabel];
        [self.bgWhiteView addSubview:self.line];
        [self.bgWhiteView addSubview:self.dutyNamesLabel];
        [self.bgWhiteView addSubview:self.endModifyTimeLabel];

        [self.bgWhiteView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(9.5f);
            make.right.equalTo(self.contentView).offset(-9.5f);
            make.top.bottom.equalTo(self.contentView);
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgWhiteView).offset(9.5f);
            make.top.equalTo(self.bgWhiteView).offset(10.0f);
        }];
        
        [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.bgWhiteView).offset(-9.5f);
            make.centerY.equalTo(self.titleLabel);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgWhiteView).offset(9.5f);
            make.right.equalTo(self.bgWhiteView).offset(-9.5f);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(17.0f);
            make.height.mas_equalTo(1.0f);
        }];
        
    
        [self.dutyNamesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgWhiteView).offset(9.5f);
            make.right.equalTo(self.bgWhiteView).offset(-9.5f);
            make.top.equalTo(self.line.mas_bottom).offset(18.0f);

        }];
        
        [self.endModifyTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgWhiteView).offset(9.5f);
            make.top.equalTo(self.dutyNamesLabel.mas_bottom).offset(11.0f);
            make.bottom.equalTo(self.bgWhiteView).offset(-10.5f);
        }];
    }
    return self;
}


- (UIView *)bgWhiteView {
    if (!_bgWhiteView) {
        _bgWhiteView = [[UIView alloc] init];
        _bgWhiteView.backgroundColor = HEX_RGB(@"#FFFFFF");
        _bgWhiteView.layer.cornerRadius = 7.5;
        _bgWhiteView.layer.masksToBounds = YES;
    }
    return _bgWhiteView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kSystemBoldFont(17) titleColor:HEX_RGB(kTitleThemeColor) textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)statusLabel {
    if (!_statusLabel) {
        _statusLabel = [[UILabel alloc] init];
        _statusLabel.font = kSystemBoldFont(17.0f);
        _statusLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _statusLabel;
}
- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#EAEAEA");
    }
    return _line;
}

- (UILabel *)dutyNamesLabel {
    if (!_dutyNamesLabel) {
        _dutyNamesLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
        _dutyNamesLabel.numberOfLines = 0;
    }
    return _dutyNamesLabel;
}

- (UILabel *)endModifyTimeLabel {
    if (!_endModifyTimeLabel) {
        _endModifyTimeLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _endModifyTimeLabel;
}



@end
